<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Class template basic_simple_event_log_backend</title>
<link rel="stylesheet" href="../../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../../../index.html" title="Chapter 1. Boost.Log v2">
<link rel="up" href="../../../sinks.html#header.boost.log.sinks.event_log_backend_hpp" title="Header &lt;boost/log/sinks/event_log_backend.hpp&gt;">
<link rel="prev" href="basic_event_log_backend.html" title="Class template basic_event_log_backend">
<link rel="next" href="event_log/make_event_id.html" title="Function make_event_id">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td></tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="basic_event_log_backend.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../../sinks.html#header.boost.log.sinks.event_log_backend_hpp"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="event_log/make_event_id.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="refentry">
<a name="boost.log.sinks.basic_simple_even_idm32821"></a><div class="titlepage"></div>
<div class="refnamediv">
<h2><span class="refentrytitle">Class template basic_simple_event_log_backend</span></h2>
<p>boost::log::sinks::basic_simple_event_log_backend — An implementation of a simple logging sink backend that emits events into Windows NT event log. </p>
</div>
<h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2>
<div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: &lt;<a class="link" href="../../../sinks.html#header.boost.log.sinks.event_log_backend_hpp" title="Header &lt;boost/log/sinks/event_log_backend.hpp&gt;">boost/log/sinks/event_log_backend.hpp</a>&gt;

</span><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> CharT<span class="special">&gt;</span> 
<span class="keyword">class</span> <a class="link" href="basic_simple_even_idm32821.html" title="Class template basic_simple_event_log_backend">basic_simple_event_log_backend</a> <span class="special">:</span>
  <span class="keyword">public</span> <span class="identifier">basic_formatted_sink_backend</span><span class="special">&lt;</span> <span class="identifier">CharT</span><span class="special">,</span> <span class="identifier">concurrent_feeding</span> <span class="special">&gt;</span>
<span class="special">{</span>
<span class="keyword">public</span><span class="special">:</span>
  <span class="comment">// types</span>
  <span class="keyword">typedef</span> <span class="identifier">base_type</span><span class="special">::</span><span class="identifier">char_type</span>   <a name="boost.log.sinks.basic_simple_even_idm32821.char_type"></a><span class="identifier">char_type</span><span class="special">;</span>               <span class="comment">// Character type. </span>
  <span class="keyword">typedef</span> <span class="identifier">base_type</span><span class="special">::</span><span class="identifier">string_type</span> <a name="boost.log.sinks.basic_simple_even_idm32821.string_type"></a><span class="identifier">string_type</span><span class="special">;</span>             <span class="comment">// String type to be used as a message text holder. </span>
  <span class="keyword">typedef</span> <span class="emphasis"><em><span class="identifier">unspecified</span></em></span>            <a name="boost.log.sinks.basic_simple_even_idm32821.event_type_mapper_type"></a><span class="identifier">event_type_mapper_type</span><span class="special">;</span>  <span class="comment">// Mapper type for the event type. </span>

  <span class="comment">// <a class="link" href="basic_simple_even_idm32821.html#boost.log.sinks.basic_simple_even_idm32821construct-copy-destruct">construct/copy/destruct</a></span>
  <a class="link" href="basic_simple_even_idm32821.html#idm32860-bb"><span class="identifier">basic_simple_event_log_backend</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span><span class="special">...</span> ArgsT<span class="special">&gt;</span> 
    <span class="keyword">explicit</span> <a class="link" href="basic_simple_even_idm32821.html#idm32863-bb"><span class="identifier">basic_simple_event_log_backend</span></a><span class="special">(</span><span class="identifier">ArgsT</span><span class="special">...</span> <span class="keyword">const</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
  <a class="link" href="basic_simple_even_idm32821.html#idm32891-bb"><span class="special">~</span><span class="identifier">basic_simple_event_log_backend</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>

  <span class="comment">// <a class="link" href="basic_simple_even_idm32821.html#idm32845-bb">public member functions</a></span>
  <span class="keyword">void</span> <a class="link" href="basic_simple_even_idm32821.html#idm32846-bb"><span class="identifier">set_event_type_mapper</span></a><span class="special">(</span><span class="identifier">event_type_mapper_type</span> <span class="keyword">const</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">void</span> <a class="link" href="basic_simple_even_idm32821.html#idm32852-bb"><span class="identifier">consume</span></a><span class="special">(</span><span class="identifier">record_view</span> <span class="keyword">const</span> <span class="special">&amp;</span><span class="special">,</span> <span class="identifier">string_type</span> <span class="keyword">const</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>

  <span class="comment">// <a class="link" href="basic_simple_even_idm32821.html#idm32894-bb">public static functions</a></span>
  <span class="keyword">static</span> <span class="identifier">string_type</span> <a class="link" href="basic_simple_even_idm32821.html#idm32895-bb"><span class="identifier">get_default_log_name</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">static</span> <span class="identifier">string_type</span> <a class="link" href="basic_simple_even_idm32821.html#idm32901-bb"><span class="identifier">get_default_source_name</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>
<span class="special">}</span><span class="special">;</span></pre></div>
<div class="refsect1">
<a name="idm67600"></a><h2>Description</h2>
<p>The sink uses Windows NT 5 (Windows 2000) and later event log API to emit events to an event log. The sink acts as an event source in terms of the API, it implements all needed resources and source registration in the Windows registry that is needed for the event delivery.</p>
<p>The backend performs message text formatting. The composed text is then passed as the first and only string parameter of the event. The resource embedded into the backend describes the event so that the parameter is inserted into the event description text, thus making it visible in the event log.</p>
<p>The backend allows to customize mapping of application severity levels to the native Windows event types. This allows to write portable code even if OS-specific sinks, such as this one, are used.</p>
<div class="note"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../../doc/src/images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>Since the backend registers itself into Windows registry as the resource file that contains event description, it is important to keep the library binary in a stable place of the filesystem. Otherwise Windows might not be able to load event resources from the library and display events correctly.</p></td></tr>
</table></div>
<p>
</p>
<div class="note"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../../doc/src/images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>It is known that Windows is not able to find event resources in the application executable, which is linked against the static build of the library. Users are advised to use dynamic builds of the library to solve this problem. </p></td></tr>
</table></div>
<p>
</p>
<div class="refsect2">
<a name="idm67610"></a><h3>
<a name="boost.log.sinks.basic_simple_even_idm32821construct-copy-destruct"></a><code class="computeroutput">basic_simple_event_log_backend</code> 
        public
       construct/copy/destruct</h3>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
<pre class="literallayout"><a name="idm32860-bb"></a><span class="identifier">basic_simple_event_log_backend</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre>
<p>Default constructor. Registers event source with name based on the application executable file name in the Application log. If such a registration is already present, it is not overridden. </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span><span class="special">...</span> ArgsT<span class="special">&gt;</span> 
  <span class="keyword">explicit</span> <a name="idm32863-bb"></a><span class="identifier">basic_simple_event_log_backend</span><span class="special">(</span><span class="identifier">ArgsT</span><span class="special">...</span> <span class="keyword">const</span> <span class="special">&amp;</span> args<span class="special">)</span><span class="special">;</span></pre>
<p>Constructor. Registers event log source with the specified parameters. The following named parameters are supported:</p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem"><p><code class="computeroutput">target</code> - Specifies an UNC path to the remote server which log records should be sent to. The local machine will be used to process log records, if not specified. </p></li>
<li class="listitem"><p><code class="computeroutput">log_name</code> - Specifies the log in which the source should be registered. The result of <code class="computeroutput">get_default_log_name</code> is used, if the parameter is not specified. </p></li>
<li class="listitem"><p><code class="computeroutput">log_source</code> - Specifies the source name. The result of <code class="computeroutput">get_default_source_name</code> is used, if the parameter is not specified. </p></li>
<li class="listitem"><p><code class="computeroutput">registration</code> - Specifies the event source registration mode in the Windows registry. Can have values of the <code class="computeroutput">registration_mode</code> enum. Default value: <code class="computeroutput">on_demand</code>.</p></li>
</ul></div>
<p>

</p>
<div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term">Parameters:</span></p></td>
<td><div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><code class="computeroutput">args</code></span></p></td>
<td><p>A set of named parameters. </p></td>
</tr></tbody>
</table></div></td>
</tr></tbody>
</table></div>
</li>
<li class="listitem">
<pre class="literallayout"><a name="idm32891-bb"></a><span class="special">~</span><span class="identifier">basic_simple_event_log_backend</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre>
<p>Destructor. Unregisters event source. The log source description is not removed from the Windows registry. </p>
</li>
</ol></div>
</div>
<div class="refsect2">
<a name="idm67681"></a><h3>
<a name="idm32845-bb"></a><code class="computeroutput">basic_simple_event_log_backend</code> public member functions</h3>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
<pre class="literallayout"><span class="keyword">void</span> <a name="idm32846-bb"></a><span class="identifier">set_event_type_mapper</span><span class="special">(</span><span class="identifier">event_type_mapper_type</span> <span class="keyword">const</span> <span class="special">&amp;</span> mapper<span class="special">)</span><span class="special">;</span></pre>
<p>The method installs the function object that maps application severity levels to WinAPI event types </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">void</span> <a name="idm32852-bb"></a><span class="identifier">consume</span><span class="special">(</span><span class="identifier">record_view</span> <span class="keyword">const</span> <span class="special">&amp;</span> rec<span class="special">,</span> <span class="identifier">string_type</span> <span class="keyword">const</span> <span class="special">&amp;</span> formatted_message<span class="special">)</span><span class="special">;</span></pre>
<p>The method puts the formatted message to the event log </p>
</li>
</ol></div>
</div>
<div class="refsect2">
<a name="idm67716"></a><h3>
<a name="idm32894-bb"></a><code class="computeroutput">basic_simple_event_log_backend</code> public static functions</h3>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
<pre class="literallayout"><span class="keyword">static</span> <span class="identifier">string_type</span> <a name="idm32895-bb"></a><span class="identifier">get_default_log_name</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre>
<p>
</p>
<div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term">Returns:</span></p></td>
<td><p>Default log name: Application </p></td>
</tr></tbody>
</table></div>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">static</span> <span class="identifier">string_type</span> <a name="idm32901-bb"></a><span class="identifier">get_default_source_name</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre>
<p>
</p>
<div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term">Returns:</span></p></td>
<td><p>Default log source name that is based on the application executable file name and the sink name </p></td>
</tr></tbody>
</table></div>
</li>
</ol></div>
</div>
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright © 2007-2021 Andrey Semashev<p>
        Distributed under the Boost Software License, Version 1.0. (See accompanying
        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>).
      </p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="basic_event_log_backend.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../../sinks.html#header.boost.log.sinks.event_log_backend_hpp"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="event_log/make_event_id.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
